package com.kmwiki.Utility.Net;

import com.kmwiki.Utility.*; 

import java.io.IOException;
import java.net.InetAddress;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class myUrl {

	public String getServerName(HttpServletRequest req){
		return req.getServerName();	
	}
	public String getLocalAddr(HttpServletRequest req){
		return req.getLocalAddr(); 	//getLocalAddr: 127.0.0.1		
	}
	public String getLocalName(HttpServletRequest req){
		return req.getLocalName();	//getLocalName: 127.0.0.1
	}
	public String getServerPort(HttpServletRequest req){
		return myString.intToStr(req.getServerPort());	//getServerPort: 8802
	}
	public String getRequestURL(HttpServletRequest req){
		return req.getRequestURL().toString();	//getRequestURL: http://localhost:8802/profile
	}
	public String getLocalNameWithPort(HttpServletRequest req){
		return String.format("http://%1$s:%2$s/"  , getServerName(req),getServerPort(req));
	}
	




		
		
}
